//
//  NSDate+Year_Moth_Day.m
//  NSDate
//
//  Created by admin on 2019/8/9.
//  Copyright © 2019 猫爷爷的酱醋茶. All rights reserved.
//

#import "NSDate+Year_Moth_Day.h"

@implementation NSDate (Year_Moth_Day)

-(int)year
{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *dateCom = [calendar components:NSCalendarUnitYear fromDate:self];
    
    return (int)dateCom.year;
}

-(int)month
{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *dateCom = [calendar components:NSCalendarUnitMonth fromDate:self];
    
    return (int)dateCom.month;
}

-(int)day
{
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *dateCom = [calendar components:NSCalendarUnitDay fromDate:self];
    
    return (int)dateCom.day;
}


@end
